package com.yami.trading.api.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yami.trading.bean.c2c.C2cAdvert;
import com.yami.trading.bean.c2c.C2cUser;
import com.yami.trading.bean.item.domain.Item;
import com.yami.trading.bean.model.C2cPaymentMethodConfig;
import com.yami.trading.bean.model.C2cTranslate;
import com.yami.trading.bean.model.User;
import com.yami.trading.bean.rate.domain.ExchangeRate;
import com.yami.trading.common.constants.Constants;
import com.yami.trading.common.domain.Result;
import com.yami.trading.common.exception.YamiShopBindException;
import com.yami.trading.common.util.DateUtils;
import com.yami.trading.common.util.StringUtils;
import com.yami.trading.security.common.util.SecurityUtils;
import com.yami.trading.service.AwsS3OSSFileService;
import com.yami.trading.service.c2c.C2cAdvertService;
import com.yami.trading.service.c2c.C2cPaymentMethodConfigService;
import com.yami.trading.service.c2c.C2cTranslateService;
import com.yami.trading.service.c2c.C2cUserService;
import com.yami.trading.service.item.ItemService;
import com.yami.trading.service.rate.ExchangeRateService;
import com.yami.trading.service.user.UserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.*;

/**
 * C2C广告
 */
@RestController
@Slf4j
public class ApiC2cAdvertController {
    @Autowired
    private C2cAdvertService c2cAdvertService;
    @Autowired
    private C2cUserService c2cUserService;
    @Autowired
    private UserService userService;
    @Autowired
    private ExchangeRateService exchangeRateService;
    @Autowired
    private ItemService itemService;
    @Autowired
    private C2cPaymentMethodConfigService c2cPaymentMethodConfigService;
//    @Autowired
//    private C2cPaymentMethodService c2cPaymentMethodService;
//    @Autowired
//    private SessionTokenService sessionTokenService;
//    @Autowired
//    private SecUserService secUserService;
//    @Autowired
//    private LogService logService;
//    @Autowired
//    private SysparaService sysparaService;
//    @Autowired
//    private C2cOrderService c2cOrderService;
//    @Autowired
//    private C2cAppealService c2cAppealService;
    @Autowired
    AwsS3OSSFileService awsS3OSSFileService;
    @Autowired
    private C2cTranslateService c2cTranslateService;
    private final String action = "/api/c2cAdvert!";

    /**
     * 获取 支付币种（法币） 列表
     */
    @RequestMapping(action + "currency.action")
    public Result currency(HttpServletRequest request) {
        Map<String, String> pmtMap = c2cAdvertService.getC2cSyspara("c2c_advert_currency");
        List<Map<String, Object>> data = new ArrayList<>();
        List<ExchangeRate> exchangeRateList =exchangeRateService.findBy(Constants.OUT_OR_IN_DEFAULT);
        for (ExchangeRate er : exchangeRateList) {
            if (pmtMap.keySet().contains(er.getCurrency())) {
                Map<String, Object> erMap = new HashMap<String, Object>();
                erMap.put("out_or_in", er.getOutOrIn());
                erMap.put("rate", er.getRata());
                erMap.put("currency", er.getCurrency());
                erMap.put("name", er.getName());
                erMap.put("currency_symbol", er.getCurrencySymbol());
                data.add(erMap);
            }
        }
        return Result.succeed(data);
    }
//
    /**
     * 获取 上架币种 列表
     */
    @RequestMapping(action + "symbol.action")
    public Result symbol(HttpServletRequest request) {
        Map<String, String> asMap =c2cAdvertService.getC2cSyspara("c2c_advert_symbol");
        Map<String, String> data = new HashMap<>();
        List<Item> itemList = itemService.cacheGetAll();
        data.put("usdt", "USDT");
        for (Item item : itemList) {
            if (asMap.keySet().contains(item.getSymbol().toUpperCase())) {
                data.put(item.getSymbol(), item.getSymbol().toUpperCase());
            }
        }
        return Result.succeed(data);
    }
////	/**
////	 * 获取 广告支付时效 列表
////	 */
////	@RequestMapping(action + "expire_time.action")
////	public Object expire_time(HttpServletRequest request) {
////
////		ResultObject resultObject = new ResultObject();
////
////		try {
////
////			Map<String, String> data = this.c2cAdvertService.getC2cSyspara("c2c_advert_expire_time");
////
////			resultObject.setData(data);
////
////		} catch (BusinessException e) {
////			resultObject.setCode("1");
////			resultObject.setMsg(e.getMessage());
////		} catch (Throwable t) {
////			resultObject.setCode("1");
////			resultObject.setMsg("程序错误");
////			logger.error("error:", t);
////		}
////
////		return resultObject;
////	}
//
    /**
     * 获取 广告 列表
     * <p>
     * direction 买卖方式：buy买/sell卖
     * currency 支付币种（大写CNY、USD、CAD等）
     * symbol 上架币种（大写USDT、BTC、ETH）
     * method_type 支付方式类型：0其它/1银行卡/2虚拟货币/3微信/4支付宝/5PayPal/6西联汇款/7SWIFT国际汇款
     * amount 支付金额：必须小于剩余派单金额
     */
    @RequestMapping(action + "list.action")
    public Result list(HttpServletRequest request) {
        String page_no = request.getParameter("page_no");
        String direction = request.getParameter("direction");
        String currency = request.getParameter("currency");
        String symbol = request.getParameter("symbol");
        String method_type = request.getParameter("method_type");
        String amount = request.getParameter("amount");
        String language = request.getParameter("language");

            String error = this.verif(direction, currency, symbol, method_type, amount);
            if (!StringUtils.isNullOrEmpty(error)) {
                throw new YamiShopBindException(error);
            }
            if (StringUtils.isNullOrEmpty(page_no)) {
                page_no = "1";
            }
            if (!StringUtils.isInteger(page_no)) {
                throw new YamiShopBindException("页码不是整数");
            }
            if (Integer.valueOf(page_no).intValue() <= 0) {
                throw new YamiShopBindException("页码不能小于等于0");
            }
            int page_no_int = Integer.valueOf(page_no).intValue();
            String partyId = SecurityUtils.getUser().getUserId();
             String c2cUserId = "";
            User party = userService.getById(partyId);
            if (null == party) {
                throw new YamiShopBindException("用户不存在");
            }
            if (Arrays.asList(1, 2).contains(party.getC2cUserType())) {
                C2cUser c2cUser = c2cUserService.getByPartyId(partyId);
                if (null != c2cUser) {
                    c2cUserId = c2cUser.getUuid().toString();
                }
            }
            Page page = c2cAdvertService.pagedQuery(page_no_int, 20, c2cUserId, direction, currency, symbol, amount, 1, 0, false);

            if (null == page) {
                return Result.succeed(new ArrayList<Map<String, Object>>());
            } else {
                List<Map<String, Object>> dataResult = new ArrayList<Map<String, Object>>();
                if (!StringUtils.isEmptyString(method_type)) {
                    List<Map<String, Object>> data = (List<Map<String, Object>>) page.getRecords();
                    for (int i = 0; i < data.size(); i++) {
                        Map<String, Object> map = data.get(i);
                        Object pay_type = map.get("pay_type");
                        if (null == pay_type) {
                            continue;
                        }
                        // 获取 Map<支付方式模板ID，支付方式模板类型>
                        Map<String, String> methodConfigIdTypeMap =c2cPaymentMethodConfigService.getMethodConfigIdTypeMap();
                        String[] payTypes = pay_type.toString().split(",");
                        for (String type : payTypes) {
                            if (method_type.equals(methodConfigIdTypeMap.get(type))) {
                                dataResult.add(map);
                                break;
                            }
                        }
                    }
                } else {
                    dataResult = (List<Map<String, Object>>) page.getRecords();
                }
                for (int i = 0; i < dataResult.size(); i++) {
                    Map<String, Object> mso = dataResult.get(i);
                    if (null != mso) {
                        int thirtyDaysOrder = 0;
                        int thirtyDaysOrderBase = 0;
                        double thirtyDaysOrderRatio = 0D;
                        double thirtyDaysOrderRatioBase = 0D;
                        if (null != mso.get("thirty_days_order") && StringUtils.isNotEmpty(mso.get("thirty_days_order").toString())) {
                            thirtyDaysOrder = Integer.valueOf(mso.get("thirty_days_order").toString()).intValue();
                        }
                        if (null != mso.get("thirty_days_order_base") && StringUtils.isNotEmpty(mso.get("thirty_days_order_base").toString())) {
                            thirtyDaysOrderBase = Integer.valueOf(mso.get("thirty_days_order_base").toString()).intValue();
                        }
                        if (null != mso.get("thirty_days_order_ratio") && StringUtils.isNotEmpty(mso.get("thirty_days_order_ratio").toString())) {
                            thirtyDaysOrderRatio = Double.valueOf(mso.get("thirty_days_order_ratio").toString()).doubleValue();
                        }
                        if (null != mso.get("thirty_days_order_ratio_base") && StringUtils.isNotEmpty(mso.get("thirty_days_order_ratio_base").toString())) {
                            thirtyDaysOrderRatioBase = Double.valueOf(mso.get("thirty_days_order_ratio_base").toString()).doubleValue();
                        }
                        mso.put("thirty_days_order", thirtyDaysOrderBase + thirtyDaysOrder);
                        mso.put("thirty_days_order_ratio", 0 != thirtyDaysOrderRatioBase ? thirtyDaysOrderRatioBase : thirtyDaysOrderRatio);
                        if (null != mso.get("head_img") && StringUtils.isNotEmpty(mso.get("head_img").toString())) {
                            String path = awsS3OSSFileService.getUrl(mso.get("head_img").toString());
                            mso.put("head_img", path);
                        }
                        if (mso.get("pay_type") != null && StringUtils.isNotEmpty(mso.get("pay_type").toString())) {
                            List<String> pay_type = new LinkedList<String>();
                            String[] types = mso.get("pay_type").toString().split(",");
                            for (String type : types) {
                                C2cPaymentMethodConfig method =c2cPaymentMethodConfigService.get(type.trim());
                                if (null != method) {
                                    C2cTranslate trans = c2cTranslateService.get(method.getMethodName(), language);
                                    if (null != trans) {
                                        pay_type.add(trans.getTranslate());
                                    } else {
                                        pay_type.add(method.getMethodName());
                                    }
                                }
                            }
                            mso.put("pay_type_name", String.join(",", pay_type));
                        }
                    }
                }
                return  Result.succeed(dataResult);
            }
    }
////	/**
////	 * 获取 承兑商广告 列表
////	 *
////	 * direction 买卖方式：buy买/sell卖
////	 * currency 支付币种（大写CNY、USD、CAD等）
////	 * symbol 上架币种（大写USDT、BTC、ETH）
////	 * on_sale 是否上架：0下架/1上架
////	 */
////	@RequestMapping(action + "list_c2c_user.action")
////	public Object list_c2c_user(HttpServletRequest request) {
////		String page_no = request.getParameter("page_no");
////		String direction = request.getParameter("direction");
////		String currency = request.getParameter("currency");
////		String symbol = request.getParameter("symbol");
////		String on_sale = request.getParameter("on_sale");
////		String language = request.getParameter("language");
////
////		ResultObject resultObject = new ResultObject();
////		resultObject = this.readSecurityContextFromSession(resultObject);
////		if (!"0".equals(resultObject.getCode())) {
////			return resultObject;
////		}
////
////		try {
////
////			String error = this.verif_c2c_user(direction, currency, symbol, on_sale);
////			if (!StringUtils.isNullOrEmpty(error)) {
////				throw new BusinessException(error);
////			}
////
////			if (StringUtils.isNullOrEmpty(page_no)) {
////				page_no = "1";
////			}
////			if (!StringUtils.isInteger(page_no)) {
////				throw new BusinessException("页码不是整数");
////			}
////			if (Integer.valueOf(page_no).intValue() <= 0) {
////				throw new BusinessException("页码不能小于等于0");
////			}
////
////			int page_no_int = Integer.valueOf(page_no).intValue();
////
////			String partyId = this.getLoginPartyId();
////			if (null == partyId) {
////				throw new BusinessException("请重新登录");
////			}
////
////			C2cUser c2cUser = this.c2cUserService.getByPartyId(partyId);
////			if (null == c2cUser) {
////				throw new BusinessException("承兑商不存在");
////			}
////
////			Integer on_sale_int = null;
////			if (StringUtils.isNotEmpty(on_sale)) {
////				on_sale_int = Integer.valueOf(on_sale);
////			}
////
////			Page page = this.c2cAdvertService.pagedQuery(page_no_int, 20, c2cUser.getId().toString(), direction, currency, symbol, "", on_sale_int, 0, true);
////			if (null == page) {
////				resultObject.setData(new ArrayList<Map<String, Object>>());
////			} else {
////				List<Map<String, Object>> dataResult = (List<Map<String, Object>>) page.getElements();
////
////				for (int i = 0; i < dataResult.size(); i++) {
////					Map<String, Object> mso = dataResult.get(i);
////					if (null != mso) {
////
////						if (mso.get("pay_type") != null && StringUtils.isNotEmpty(mso.get("pay_type").toString())) {
////							List<String> pay_type = new LinkedList<String>();
////							String[] types = mso.get("pay_type").toString().split(",");
////							for (String type : types) {
////								C2cPaymentMethodConfig method = this.c2cPaymentMethodConfigService.get(type.trim());
////								if (null != method) {
////									C2cTranslate trans = this.c2cTranslateService.get(method.getMethodName(), language);
////									if (null != trans) {
////										pay_type.add(trans.getTranslate());
////									} else {
////										pay_type.add(method.getMethodName());
////									}
////								}
////							}
////							mso.put("pay_type_name", String.join(",", pay_type));
////						}
////					}
////				}
////
////				resultObject.setData(dataResult);
////			}
////
////		} catch (BusinessException e) {
////			resultObject.setCode("1");
////			resultObject.setMsg(e.getMessage());
////		} catch (Throwable t) {
////			resultObject.setCode("1");
////			resultObject.setMsg("程序错误");
////			logger.error("error:", t);
////		}
////
////		return resultObject;
////	}
////	/**
////	 * 获取 承兑商广告 历史列表
////	 *
////	 * direction 买卖方式：buy买/sell卖
////	 */
////	@RequestMapping(action + "list_history.action")
////	public Object list_history(HttpServletRequest request) {
////		String page_no = request.getParameter("page_no");
////		String direction = request.getParameter("direction");
////		String language = request.getParameter("language");
////
////		ResultObject resultObject = new ResultObject();
////		resultObject = this.readSecurityContextFromSession(resultObject);
////		if (!"0".equals(resultObject.getCode())) {
////			return resultObject;
////		}
////
////		try {
////
////			if (!StringUtils.isEmptyString(direction) && !Arrays.asList("buy", "sell").contains(direction)) {
////				throw new BusinessException("买卖方式不正确");
////			}
////
////			if (StringUtils.isNullOrEmpty(page_no)) {
////				page_no = "1";
////			}
////			if (!StringUtils.isInteger(page_no)) {
////				throw new BusinessException("页码不是整数");
////			}
////			if (Integer.valueOf(page_no).intValue() <= 0) {
////				throw new BusinessException("页码不能小于等于0");
////			}
////
////			int page_no_int = Integer.valueOf(page_no).intValue();
////
////			String partyId = this.getLoginPartyId();
////			if (null == partyId) {
////				throw new BusinessException("请重新登录");
////			}
////
////			C2cUser c2cUser = this.c2cUserService.getByPartyId(partyId);
////			if (null == c2cUser) {
////				throw new BusinessException("承兑商不存在");
////			}
////
////			Page page = this.c2cAdvertService.pagedQuery(page_no_int, 20, c2cUser.getId().toString(), direction, "", "", "", null, 1, true);
////			if (null == page) {
////				resultObject.setData(new ArrayList<Map<String, Object>>());
////			} else {
////				List<Map<String, Object>> dataResult = (List<Map<String, Object>>) page.getElements();
////
////				for (int i = 0; i < dataResult.size(); i++) {
////					Map<String, Object> mso = dataResult.get(i);
////					if (null != mso) {
////
////						if (mso.get("pay_type") != null && StringUtils.isNotEmpty(mso.get("pay_type").toString())) {
////							List<String> pay_type = new LinkedList<String>();
////							String[] types = mso.get("pay_type").toString().split(",");
////							for (String type : types) {
////								C2cPaymentMethodConfig method = this.c2cPaymentMethodConfigService.get(type.trim());
////								if (null != method) {
////									C2cTranslate trans = this.c2cTranslateService.get(method.getMethodName(), language);
////									if (null != trans) {
////										pay_type.add(trans.getTranslate());
////									} else {
////										pay_type.add(method.getMethodName());
////									}
////								}
////							}
////							mso.put("pay_type_name", String.join(",", pay_type));
////						}
////					}
////				}
////
////				resultObject.setData(dataResult);
////			}
////
////		} catch (BusinessException e) {
////			resultObject.setCode("1");
////			resultObject.setMsg(e.getMessage());
////		} catch (Throwable t) {
////			resultObject.setCode("1");
////			resultObject.setMsg("程序错误");
////			logger.error("error:", t);
////		}
////
////		return resultObject;
////	}
//

    /**
     * 获取 广告 详情
     * <p>
     * id C2C广告ID
     */
    @RequestMapping(action + "get.action")
    public Result get(HttpServletRequest request) {

        String id = request.getParameter("id");
        String language = request.getParameter("language");
        if (StringUtils.isEmptyString(id)) {
            throw new YamiShopBindException("C2C广告id不正确");
        }
        C2cAdvert c2cAdvert = c2cAdvertService.getById(id);
        if (null == c2cAdvert) {
            throw new YamiShopBindException("广告不存在");
        }
        C2cUser c2cUser = this.c2cUserService.getById(c2cAdvert.getC2cUserId());
        if (null == c2cUser) {
            throw new YamiShopBindException("承兑商不存在");
        }
        User c2cParty = userService.getById(c2cUser.getC2cUserPartyId());
        if (null == c2cParty) {
            throw new YamiShopBindException("承兑商的用户信息不存在");
        }
        Map<String, String> data = new HashMap<String, String>();
        data.put("id", c2cAdvert.getUuid().toString());
        data.put("direction", c2cAdvert.getDirection());
        data.put("currency", c2cAdvert.getCurrency());
        data.put("symbol", c2cAdvert.getSymbol());
        data.put("pay_rate", String.valueOf(c2cAdvert.getPayRate()));
        data.put("pay_type", c2cAdvert.getPayType());
        data.put("symbol_value", String.valueOf(c2cAdvert.getSymbolValue()));
        data.put("coin_amount", String.valueOf(c2cAdvert.getCoinAmount()));
        data.put("investment_min", String.valueOf(c2cAdvert.getInvestmentMin()));
        data.put("investment_max", String.valueOf(c2cAdvert.getInvestmentMax()));
        data.put("deposit", String.valueOf(c2cAdvert.getDeposit()));
        data.put("deposit_open", String.valueOf(c2cAdvert.getDepositOpen()));
        data.put("on_sale", String.valueOf(c2cAdvert.getOnSale()));
        data.put("sort_index", String.valueOf(c2cAdvert.getSortIndex()));
        data.put("expire_time", String.valueOf(c2cAdvert.getExpireTime()));
        data.put("transaction_terms", c2cAdvert.getTransactionTerms());
        data.put("order_msg", c2cAdvert.getOrderMsg());
        data.put("remark", c2cAdvert.getRemark());
        data.put("create_time", DateUtils.format(c2cAdvert.getCreateTime(), DateUtils.DF_yyyyMMddHHmmss));
        data.put("update_time", DateUtils.format(c2cAdvert.getUpdateTime(), DateUtils.DF_yyyyMMddHHmmss));
        data.put("c2c_user_id", c2cUser.getUuid().toString());
        data.put("nick_name", c2cUser.getNickName());
        data.put("c2c_user_type", String.valueOf(c2cUser.getC2cUserType()));
        data.put("c2c_user_code", c2cUser.getC2cUserCode());
        data.put("party_id", c2cParty.getUserId().toString());
        data.put("user_code", c2cParty.getUserCode());
        data.put("user_name", c2cParty.getUserName());
        if (StringUtils.isNotEmpty(c2cUser.getHeadImg())) {
            String path = awsS3OSSFileService.getUrl(c2cUser.getHeadImg());
            data.put("head_img", path);
        } else {
            data.put("head_img", "");
        }
        if (data.get("pay_type") != null && StringUtils.isNotEmpty(data.get("pay_type").toString())) {
            List<String> pay_type = new LinkedList<String>();
            String[] types = data.get("pay_type").toString().split(",");
            for (String type : types) {
                C2cPaymentMethodConfig method = this.c2cPaymentMethodConfigService.get(type.trim());
                if (null != method) {
                    C2cTranslate trans = this.c2cTranslateService.get(method.getMethodName(), language);
                    if (null != trans) {
                        pay_type.add(trans.getTranslate());
                    } else {
                        pay_type.add(method.getMethodName());
                    }
                }
            }
            data.put("pay_type_name", String.join(",", pay_type));
        }
        return Result.succeed(data);
    }


//
//    private String verif_add(String coin_amount, String direction, String pay_type, String currency,
//                             String symbol, String symbol_value, String investment_min, String investment_max, String on_sale, String expire_time, String safeword) {
//        if (StringUtils.isEmptyString(coin_amount) || !StringUtils.isDouble(coin_amount) || Double.valueOf(coin_amount).doubleValue() <= 0) {
//            return "交易数量不正确";
//        }
//        if (StringUtils.isEmptyString(direction) || !Arrays.asList("buy", "sell").contains(direction)) {
//            return "买卖方式不正确";
//        }
//        if (StringUtils.isEmptyString(pay_type)) {
//            return "支付方式不正确";
//        }
//        Map<String, String> currencyMap = this.c2cAdvertService.getCurrencyMap();
//        Map<String, String> symbolMap = this.c2cAdvertService.getSymbolMap();
//        if (StringUtils.isEmptyString(currency) || null == currencyMap || (null != currencyMap && !currencyMap.containsKey(currency))) {
//            return "支付币种不正确";
//        }
//        if (StringUtils.isEmptyString(symbol) || null == symbolMap || (null != symbolMap && !symbolMap.containsKey(symbol))) {
//            return "上架币种不正确";
//        }
//        if (StringUtils.isEmptyString(symbol_value) || !StringUtils.isDouble(symbol_value) || Double.valueOf(symbol_value).doubleValue() <= 0) {
//            return "币种单价不正确";
//        }
//        if (StringUtils.isEmptyString(investment_min) || !StringUtils.isDouble(investment_min) || Double.valueOf(investment_min).doubleValue() <= 0) {
//            return "单笔订单最低限额未填或格式不正确";
//        }
//        if (StringUtils.isEmptyString(investment_max) || !StringUtils.isDouble(investment_max) || Double.valueOf(investment_max).doubleValue() <= 0) {
//            return "单笔订单最高限额未填或格式不正确";
//        }
//        if (StringUtils.isEmptyString(on_sale) || !Arrays.asList("0", "1").contains(on_sale)) {
//            return "是否上架未填或格式不正确";
//        }
//        Map<String, String> aetMap = this.c2cAdvertService.getC2cSyspara("c2c_advert_expire_time");
//        if (StringUtils.isEmptyString(expire_time) || !aetMap.keySet().contains(expire_time)) {
//            return "支付时效未填或格式不正确";
//        }
//        if (StringUtils.isEmptyString(safeword)) {
//            return "资金密码错误";
//        }
//        return null;
//    }
//
    private String verif(String direction, String currency, String symbol, String method_type, String amount) {
        if (!StringUtils.isEmptyString(direction) && !Arrays.asList("buy", "sell").contains(direction)) {
            return "买卖方式不正确";
        }
        Map<String, String> currencyMap = this.c2cAdvertService.getCurrencyMap();
        Map<String, String> symbolMap = this.c2cAdvertService.getSymbolMap();
        if (!StringUtils.isEmptyString(currency) && null != currencyMap && !currencyMap.containsKey(currency)) {
            return "支付币种不正确";
        }
        if (!StringUtils.isEmptyString(symbol) && null != symbolMap && !symbolMap.containsKey(symbol)) {
            return "上架币种不正确";
        }
        Map<String, String> pmtMap = this.c2cAdvertService.getC2cSyspara("c2c_payment_method_type");
        if (!StringUtils.isEmptyString(method_type) && !pmtMap.keySet().contains(method_type)) {
            return "支付方式类型不正确";
        }
        if (!StringUtils.isEmptyString(amount) && (!StringUtils.isDouble(amount) || Double.valueOf(amount).doubleValue() < 0)) {
            return "支付金额不正确";
        }
        return null;
    }
//
//    private String verif_c2c_user(String direction, String currency, String symbol, String on_sale) {
//        if (!StringUtils.isEmptyString(direction) && !Arrays.asList("buy", "sell").contains(direction)) {
//            return "买卖方式不正确";
//        }
//        Map<String, String> currencyMap = this.c2cAdvertService.getCurrencyMap();
//        Map<String, String> symbolMap = this.c2cAdvertService.getSymbolMap();
//        if (!StringUtils.isEmptyString(currency) && null != currencyMap && !currencyMap.containsKey(currency)) {
//            return "支付币种不正确";
//        }
//        if (!StringUtils.isEmptyString(symbol) && null != symbolMap && !symbolMap.containsKey(symbol)) {
//            return "上架币种不正确";
//        }
//        if (!StringUtils.isEmptyString(on_sale) && !Arrays.asList("0", "1").contains(on_sale)) {
//            return "是否上架不正确";
//        }
//        return null;
//    }
//
//    public void saveLog(SecUser secUser, String operator, String context, String category) {
//        project.log.Log log = new project.log.Log();
//        log.setCategory(category);
//        log.setOperator(operator);
//        log.setUsername(secUser.getUsername());
//        log.setPartyId(secUser.getPartyId());
//        log.setLog(context);
//        log.setCreateTime(new Date());
//        this.logService.saveSync(log);
//    }
}
